#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int, int>
const int N = 1e5+5;
int n, m, L, V, d[N], v[N], a[N], p[N], cnt, res;

void solve() {
    cnt = res = 0;
    cin >> n >> m >> L >> V;
    vector<pii> nee;
    for (int i = 1; i <= n; ++i) cin >> d[i] >> v[i] >> a[i];
    for (int i = 1; i <= m; ++i) cin >> p[i];
    for (int i = 1; i <= n; ++i) {
        if (p[m] < d[i]) continue;
        if (a[i] < 0) {
            if (v[i] <= V) {
                continue;
            }
            int ft = lower_bound(p+1, p+m+1, d[i]) - p;
            int fd = p[ft] - d[i];
            if (fd*a[i]*2 + v[i]*v[i]>V*V) {
                ++cnt;
                int lt = lower_bound(p+1, p+m+1, (double)((double)d[i]+(double)((V*V - v[i]*v[i])/(2*a[i])))) - p;
                --lt;
                nee.push_back({ft, lt});
            }
        } else if (a[i] == 0) {
            if (v[i] <= V) continue;
            nee.push_back({1, m});
            ++cnt;
        } else {
            if (v[i] > V) {
                nee.push_back({1, m});
                ++cnt;
                continue;
            }
            int ld = p[m] - d[i];
            if (ld*a[i]*2 + v[i]*v[i]>V*V) {
                ++cnt;
                int ft = upper_bound(p+1, p+m+1, (double)((double)d[i]+(double)(V*V - v[i]*v[i])/(2*a[i]))) - p;
                nee.push_back({ft, m});
            }
        }
    }
    sort(nee.begin(), nee.end());
    int last, nxt[N];
    memset(nxt, 0, sizeof(nxt));
    if (nee.size()) res = 1, last = 0, nxt[last] = 1;
    for (int i = 1; i < nee.size(); ++i) {
        while (nxt[last] && nee[i].first > nee[last].second) last = nxt[last];
        if (!nxt[last] || last == 1) {
            ++res;
            continue;
        }
        if (nee[i].second < nee[last].second) {
            int temp = last;
            last = i;
            nxt[last] = temp;
        } else {
            nxt[last] = (nee[nxt[last]].second > nee[i].second ? i : nxt[last]);
        }
    }
    cout << cnt << " " << m - res << "\n";
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}